package com.langxin.site.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.langxin.site.biz.NewsBiz;
import com.langxin.site.biz.PrecautionsBiz;
import com.langxin.site.biz.ProductBiz;
import com.langxin.site.biz.ReactionBiz;
import com.langxin.site.biz.TourBiz;
import com.langxin.site.dao.IndexDao;
import com.langxin.site.util.constant.SiteConstant;

/**
 * 首页
 * @author guqj
 *
 */
@Controller
public class IndexAction {

	@Autowired
	private IndexDao     indexDao;
	@Autowired
	private TourBiz      tourBiz;
	@Autowired
	private ProductBiz   productBiz;
	@Autowired
	private ReactionBiz  reactionBiz;
	@Autowired
	private PrecautionsBiz   precautionsBiz;
	@Autowired
	private NewsBiz      newsBiz;
	
	
	/**
	 * 首页
	 * @return
	 */
	@RequestMapping(value = "/", method = RequestMethod.GET)
	public String home(Model model){
		model.addAttribute("banners", indexDao.queryBanner());
		model.addAttribute("ads", indexDao.queryAd());
		model.addAttribute("tours", tourBiz.queryList(null, 8));
		model.addAttribute("prods", productBiz.queryList(null, 4));
		model.addAttribute("reacts", reactionBiz.queryList(null, 4, null));
		model.addAttribute("notices", precautionsBiz.queryList(null, 10, SiteConstant.NOTICE_TYPE_1, null));
		model.addAttribute("things", precautionsBiz.queryList(null, 10, SiteConstant.NOTICE_TYPE_0, null));
		model.addAttribute("news", newsBiz.queryList(null, 10, null));
		model.addAttribute("hots", newsBiz.queryList(null, 10, "T." + SiteConstant.ORDER_READ_TIME + " " + SiteConstant.DESC));
		return "index.jsp";
	}
}
